import pandas as pd
import numpy as np
from common_func_defs import *
from datetime import datetime, timedelta, date
from dateutil.relativedelta import relativedelta


####################################################### 私有函数定义 ########################################################

'''—————————————————————————————方法：从数据库取数—————————————————————————————————————————————————'''
def get_data_from_mysql(session, begin_date: str, end_date: str, table_class, varlist: list = []):
    query = session.query(table_class).filter(and_(table_class.stat_time >= begin_date,
                                            table_class.stat_time <= end_date))
    df = pd.read_sql(query.statement, session.bind)
    if varlist:
        df = df[varlist]
        return df
    else:
        return df



####################################################### 预测方法定义 ########################################################

'''—————————————————————————————方法：预测竞店目标月GMV———————————————————————————————————'''
def predict_competing_gmv_month(begin_month: str, end_month: str, platform: str):
    # 判断平台，对相应表名及字段进行调整
    if platform == '抖音':
        table_class = dy_brand_competing_brand_gmv_month
        competing_name = 'competing_brand_name'
        competing_gmv = 'competing_brand_gmv'

    elif platform == '天猫':
        table_class = tmall_flagship_store_competing_store_gmv_month
        competing_name = 'competing_store_name'
        competing_gmv = 'competing_store_gmv'

    else:
        print('请输入正确平台名！（天猫/抖音）')

    # 获取前一年同期的时间范围
    last_year_begin_month = (datetime.strptime(begin_month, '%Y-%m') - relativedelta(years=1)).strftime(
        '%Y-%m')
    last_year_end_month = (datetime.strptime(end_month, '%Y-%m') - relativedelta(years=1)).strftime(
        '%Y-%m')
    last_year_first_month = (datetime(datetime.strptime(last_year_begin_month, '%Y-%m').year, 1, 1)).strftime(
        '%Y-%m')

    # 获取前一年的数据（从去年1月到去年的end_month对应月，因为预测需要用到去年1月到该月的数据）
    session = get_session()
    df = get_data_from_mysql(session=session, begin_date=last_year_first_month,
                             end_date=last_year_end_month,
                             table_class=table_class,
                             varlist=['stat_time', competing_name, competing_gmv,
                                      'last_year_same_period_gmv', 'gmv_yoy_growth'])
    session.close()
    df = df.fillna(np.nan)  # 将所有None转化为nan，避免运算时报错

    df['stat_time'] = pd.to_datetime(df['stat_time'])
    last_year_begin_month = pd.to_datetime(last_year_begin_month)
    last_year_end_month = pd.to_datetime(last_year_end_month)

    if df[(df['stat_time'] >= last_year_begin_month) & (df['stat_time'] <= last_year_end_month)].empty:
        return None

    # 形成预测表格，计算预测值
    end_month_update = (datetime.strptime(end_month, '%Y-%m') + relativedelta(months=1)).strftime('%Y-%m') # endmonth多取一个月，否则没有结尾月的数据
    dates = pd.date_range(start=begin_month, end=end_month_update, freq='M').strftime('%Y-%m')
    prediction = pd.DataFrame({'stat_time': dates})
    competing_store = pd.DataFrame(df[competing_name].unique(), columns=[competing_name])

    # 使用merge函数进行笛卡尔积操作（形成所有竞店在每个时段上的df）
    prediction = pd.merge(prediction, competing_store, how='cross')
    prediction['stat_time'] = pd.to_datetime(prediction['stat_time'])  # 统一转为time格式，方便匹配

    for i in range(len(prediction)):
        # 筛选出去年同期的数据（从去年1月份开始到去年目标月）
        current_month = pd.to_datetime(prediction.loc[i, 'stat_time'])
        last_year_same_month = current_month - pd.DateOffset(years=1)
        last_year_first_month = last_year_same_month.replace(month=1)
        # last_year_first_month_str = last_year_first_month.strftime('%Y-%m')
        # current_month_str = current_month.strftime('%Y-%m')
        # last_year_same_month_str = last_year_same_month.strftime('%Y-%m')
        current_store_name = prediction.loc[i, competing_name]
        last_year_same_month_data = df[(df['stat_time'] >= last_year_first_month) & (df['stat_time'] <= last_year_same_month) & (df[competing_name] == current_store_name)]

        if last_year_same_month_data[last_year_same_month_data['stat_time'] == last_year_same_month].empty:
            continue

        # 计算三个同比率
        if last_year_same_month_data['gmv_yoy_growth'].sum() == 0 or last_year_same_month_data[competing_gmv].sum() == 0:
            min_rate = np.nan
            max_rate = np.nan
            weighted_rate = np.nan
        else:
            min_rate = last_year_same_month_data['gmv_yoy_growth'].min()
            max_rate = last_year_same_month_data['gmv_yoy_growth'].max()
            df_cleaned = last_year_same_month_data.dropna(subset=['gmv_yoy_growth', competing_gmv])  # 删去空值行，防止加权平均数计算为空
            weighted_rate = np.average(df_cleaned['gmv_yoy_growth'], weights=df_cleaned[competing_gmv])

        # 得到去年对应月份的gmv值
        if not last_year_same_month_data[last_year_same_month_data['stat_time'] == last_year_same_month][competing_gmv].empty:
            gmv_last_year = last_year_same_month_data[last_year_same_month_data['stat_time'] == last_year_same_month][competing_gmv].iloc[0]
        else:
            gmv_last_year = np.nan

        # 得到三个预测值
        min_predict_value = gmv_last_year * (1 + min_rate)
        max_predict_value = gmv_last_year * (1 + max_rate)
        weighted_mean_predict_value = gmv_last_year * (1 + weighted_rate)

        # 存储数据到dataframe
        prediction.loc[i, 'last_year_same_period_gmv'] = gmv_last_year
        prediction.loc[i, 'min_gmv_yoy_growth'] = min_rate
        prediction.loc[i, 'max_gmv_yoy_growth'] = max_rate
        prediction.loc[i, 'weighted_gmv_yoy_growth'] = weighted_rate
        prediction.loc[i, 'predict_min_predict_gmv'] = min_predict_value
        prediction.loc[i, 'predict_max_predict_gmv'] = max_predict_value
        prediction.loc[i, 'predict_weighted_predict_gmv'] = weighted_mean_predict_value

    # 将时间列格式调整为“年-月”
    prediction['stat_time'] = prediction['stat_time'].apply(lambda x: x.strftime('%Y-%m'))

    # 添加排名0326
    prediction['min_predict_rank'] = prediction.groupby('stat_time')['predict_min_predict_gmv'].rank(ascending=False,
                                                                                                     method='min')
    prediction['max_predict_rank'] = prediction.groupby('stat_time')['predict_max_predict_gmv'].rank(ascending=False,
                                                                                                     method='min')
    prediction['weighted_predict_rank'] = prediction.groupby('stat_time')['predict_weighted_predict_gmv'].rank(ascending=False,
                                                                                                     method='min')


    # 转中文字段名
    prediction = prediction.rename(columns={
        'stat_time': '预测时间（月份）',
        competing_name: '竞店店铺名称',
        'last_year_same_period_gmv': '上一年同期GMV',
        'min_gmv_yoy_growth': '分月最小同比率',
        'max_gmv_yoy_growth': '分月最大同比率',
        'weighted_gmv_yoy_growth': '分月加权同比率',
        'predict_min_predict_gmv': '预测最小GMV',
        'predict_max_predict_gmv': '预测最大GMV',
        'predict_weighted_predict_gmv': '预测加权GMV',
        'min_predict_rank': '预测最小GMV排名',
        'max_predict_rank': '预测最大GMV排名',
        'weighted_predict_rank': '预测加权GMV排名'
    })

    return prediction


'''—————————————————————————————方法：预测竞店大促GMV—————————————————————————————————————'''
def predict_competing_gmv_big_promotion(big_promotion_year: str, big_promotion_name: str, platform: str):
    # 判断平台，对相应表名及字段进行调整
    if platform == '抖音':
        table_class = dy_brand_competing_brand_gmv_month
        competing_name = 'competing_brand_name'
        competing_gmv = 'competing_brand_gmv'
        table_class_day = dy_competing_brand_gmv_day

    elif platform == '天猫':
        table_class = tmall_flagship_store_competing_store_gmv_month
        competing_name = 'competing_store_name'
        competing_gmv = 'competing_store_gmv'
        table_class_day = tmall_flagship_competing_store_gmv_day

    else:
        print('请输入正确平台名！（天猫/抖音）')

    # 获取大促起始日期
    session = get_session()
    query = session.query(big_promotion_duration)
    df_big_promotion = pd.read_sql(query.statement, session.bind)
    session.close()
    df_big_promotion['big_promotion_name'] = df_big_promotion['big_promotion_name'].astype(str)
    df_big_promotion['big_promotion_year'] = df_big_promotion['big_promotion_year'].astype(str)

    if df_big_promotion[(df_big_promotion['big_promotion_name'] == big_promotion_name) & (df_big_promotion['big_promotion_year'] == big_promotion_year)].empty:
        return None

    big_promotion_begin_date = df_big_promotion[(df_big_promotion['big_promotion_name'] == big_promotion_name) & (df_big_promotion['big_promotion_year'] == big_promotion_year)]['big_promotion_begin_date'].iloc[0]
    big_promotion_end_date = df_big_promotion[(df_big_promotion['big_promotion_name'] == big_promotion_name) & (df_big_promotion['big_promotion_year'] == big_promotion_year)]['big_promotion_end_date'].iloc[0]
    big_promotion_begin_date = pd.to_datetime(big_promotion_begin_date)
    big_promotion_end_date = pd.to_datetime(big_promotion_end_date)

    # 去年对应的日期
    last_year_begin_month = (big_promotion_begin_date - relativedelta(years=1)).strftime(
        '%Y-%m')
    # last_year_end_month = (big_promotion_end_date - relativedelta(years=1)).strftime(
    #     '%Y-%m')
    last_year_first_month = (datetime(datetime.strptime(last_year_begin_month, '%Y-%m').year, 1, 1)).strftime(
        '%Y-%m')
    last_year_begin_date = (big_promotion_begin_date - relativedelta(years=1)).strftime('%Y-%m-%d')
    last_year_end_date = (big_promotion_end_date - relativedelta(years=1)).strftime('%Y-%m-%d')

    # 获取所需时间段的月度gmv数据
    session = get_session()
    query = session.query(table_class).filter(and_(table_class.stat_time >= last_year_first_month,
                                            table_class.stat_time <=last_year_begin_month))
    df_month = pd.read_sql(query.statement, session.bind)
    df_month['stat_time'] = pd.to_datetime(df_month['stat_time'])
    df_month = df_month.fillna(np.nan)  # 将所有None转化为nan，避免运算时报错
    session.close()

    last_year_begin_month = pd.to_datetime(last_year_begin_month)
    if df_month[(df_month['stat_time'] == last_year_begin_month)].empty:
        return None

    # 获取所需时间段的日gmv数据
    session = get_session()
    query = session.query(table_class_day).filter(and_(table_class_day.stat_time >= last_year_begin_date,
                                            table_class_day.stat_time <= last_year_end_date))
    df_day = pd.read_sql(query.statement, session.bind)
    df_day['stat_time'] = pd.to_datetime(df_day['stat_time'])
    df_day = df_day.fillna(np.nan)  # 将所有None转化为nan，避免运算时报错
    session.close()

    if df_day.empty:
        return None

    # 形成预测表格，计算预测值
    prediction = pd.DataFrame({'big_promotion_year': [big_promotion_year], 'big_promotion_name': [big_promotion_name], 'big_promotion_begin_date': [big_promotion_begin_date], 'big_promotion_end_date': [big_promotion_end_date]})
    competing_store = pd.DataFrame(df_day[competing_name].unique(), columns=[competing_name])
    # 使用merge函数进行笛卡尔积操作（形成所有竞店在每个时段上的df）
    prediction = pd.merge(prediction, competing_store, how='cross')

    for i in range(len(prediction)):
        # 筛选出该店铺的同比数据
        current_store_name = prediction.loc[i, competing_name]
        last_year_same_month_data = df_month[(df_month[competing_name] == current_store_name)]

        if last_year_same_month_data.empty:
            continue

        # 计算三个同比率及basegmv
        if last_year_same_month_data['gmv_yoy_growth'].sum() == 0 or last_year_same_month_data[competing_gmv].sum() == 0:
            min_rate = np.nan
            max_rate = np.nan
            weighted_rate = np.nan
        else:
            min_rate = last_year_same_month_data['gmv_yoy_growth'].min()
            max_rate = last_year_same_month_data['gmv_yoy_growth'].max()
            df_cleaned = last_year_same_month_data.dropna(subset=['gmv_yoy_growth', competing_gmv])  # 删去空值行，防止加权平均数计算为空
            weighted_rate = np.average(df_cleaned['gmv_yoy_growth'], weights=df_cleaned[competing_gmv])
        base_gmv = df_day[(df_day[competing_name] == current_store_name)][competing_gmv].sum()

        # 得到三个预测值
        min_predict_value = base_gmv * (1 + min_rate)
        max_predict_value = base_gmv * (1 + max_rate)
        weighted_mean_predict_value = base_gmv * (1 + weighted_rate)

        # 存储数据到dataframe
        prediction.loc[i, 'last_year_same_period_gmv'] = base_gmv
        prediction.loc[i, 'min_gmv_yoy_growth'] = min_rate
        prediction.loc[i, 'max_gmv_yoy_growth'] = max_rate
        prediction.loc[i, 'weighted_gmv_yoy_growth'] = weighted_rate
        prediction.loc[i, 'predict_min_predict_gmv'] = min_predict_value
        prediction.loc[i, 'predict_max_predict_gmv'] = max_predict_value
        prediction.loc[i, 'predict_weighted_predict_gmv'] = weighted_mean_predict_value

    # 将时间列格式调整为“年-月-日”
    prediction['big_promotion_begin_date'] = prediction['big_promotion_begin_date'].apply(lambda x: x.strftime('%Y-%m-%d'))
    prediction['big_promotion_end_date'] = prediction['big_promotion_end_date'].apply(lambda x: x.strftime('%Y-%m-%d'))

    # 添加排名0401
    prediction['min_predict_rank'] = prediction['predict_min_predict_gmv'].rank(ascending=False,method='min')
    prediction['max_predict_rank'] = prediction['predict_max_predict_gmv'].rank(ascending=False,method='min')
    prediction['weighted_predict_rank'] = prediction['predict_weighted_predict_gmv'].rank(ascending=False,method='min')

    # 转中文字段名
    prediction = prediction.rename(columns={
        'big_promotion_year': '大促年份',
        'big_promotion_name': '大促名',
        'big_promotion_begin_date': '大促开始日期',
        'big_promotion_end_date': '大促结束日期',
        competing_name: '竞店店铺名称',
        'last_year_same_period_gmv': '上一年同期GMV',
        'min_gmv_yoy_growth': '分月最小同比率',
        'max_gmv_yoy_growth': '分月最大同比率',
        'weighted_gmv_yoy_growth': '分月加权同比率',
        'predict_min_predict_gmv': '预测最小GMV',
        'predict_max_predict_gmv': '预测最大GMV',
        'predict_weighted_predict_gmv': '预测加权GMV',
        'min_predict_rank': '预测最小GMV排名',
        'max_predict_rank': '预测最大GMV排名',
        'weighted_predict_rank': '预测加权GMV排名'
    })

    return prediction


'''—————————————————————————————方法：预测推广GMV————————————————————————————————————————'''
def predict_promotion_creativity(promotion_channel:str, promotion_time:str, cost_input:float, creativity_kind:str, good_series:str='', sixty_nine_code:str='', actual_price_min:float='', actual_price_max:float=''):
    # 当promotion_channel为品销宝时，除creativity_kind以外的其他参数都不传递（默认值为空）；若为万相台，则产品相关的四个参数都应该传递值
    if promotion_channel == '万相台':
        # 若为万相台，则产品相关的四个参数都应该传递值
        if not (good_series and sixty_nine_code and actual_price_min and actual_price_max):
            return tuple([False, None, '当渠道选择为万相台，请完整传入good_series、sixty_nine_code和最大最小actual_price参数'])

        # 读取数据
        session = get_session()
        query = session.query(wxt_cost_top_20_creativity_promotion_day)
        df = pd.read_sql(query.statement, session.bind)
        # query_img = session.query(wxt_creativity_promotion_creativity_img)
        # df_img = pd.read_sql(query_img.statement, session.bind)
        # df_img = df_img[['creativity_id', 'creativity_image_url', 'creativity_image']]
        query_input = session.query(creativity_promotion_creativity_kind_input)
        df_input = pd.read_sql(query_input.statement, session.bind)
        df_input = df_input[
            ['creativity_promotion_channel', 'creativity_id', 'creativity_image', 'creativity_image_url',
             'creativity_kind']]
        df_input = df_input[df_input['creativity_promotion_channel'] == '万相台']
        session.close()

        # 说明字段增加
        df = df.assign(creativity_delivery_platform='天猫')
        df = df.assign(promotion_channel='万相台')

        # 进行连表
        # df = pd.merge(df, df_img, on=['creativity_id'], how='left')
        # df = pd.merge(df, df_input, on=['creativity_id', 'creativity_image'], how='left')
        df = pd.merge(df, df_input, on=['creativity_id'], how='left')

        # 筛选所需字段
        df = df[
            ['stat_time', 'creativity_delivery_platform', 'promotion_channel', 'creativity_id', 'creativity_name',
             'creativity_image',
             'creativity_kind', 'entity_id', 'entity_kind', 'entity_name', 'sixty_nine_code', 'good_series',
             'good_product_combination', 'good_actual_price', 'click_through_rate', 'click_conversion_rate', 'cost',
             'total_trans_amount', 'roi']
        ]

        df['stat_time'] = pd.to_datetime(df['stat_time'])
        df = df.fillna(np.nan)  # 将所有None转化为nan，避免运算时报错

        # 筛选creativity_kind, good_series, sixty_nine_code, actual_price
        df = df[(df['creativity_kind'] == creativity_kind) & (df['good_series'] == good_series) & (df['sixty_nine_code'] == sixty_nine_code)]
        df = df[(df['good_actual_price'] <= actual_price_max) & (df['good_actual_price'] >= actual_price_min)]

        if df.empty:
            return None

        # 筛选历史数据（时间）
        promotion_time = pd.to_datetime(promotion_time)
        if not df[(df['stat_time'].dt.month == promotion_time.month)].empty:
            df = df[(df['stat_time'].dt.month == promotion_time.month)]
        elif not df[(df['stat_time'].dt.quarter == promotion_time.quarter)].empty:
            df = df[(df['stat_time'].dt.quarter == promotion_time.quarter)]
        else:
            pass

        # 预测数据生成
        predict_click_through_rate = df['click_through_rate'].mean()
        predict_click_conversion_rate = df['click_conversion_rate'].mean()
        predict_roi = df['roi'].mean()
        prediction = pd.DataFrame({'creativity_delivery_platform': ['天猫'], 'promotion_channel': ['万相台'],
                                   'promotion_time': [promotion_time], 'good_series': [good_series],
                                   'sixty_nine_code': [sixty_nine_code],
                                   'actual_price_min': [actual_price_min], 'actual_price_max': [actual_price_max],
                                   'creativity_kind': [creativity_kind],
                                   'predict_click_through_rate': [predict_click_through_rate],
                                   'predict_click_conversion_rate': [predict_click_conversion_rate], 'predict_roi': [predict_roi],
                                   'cost': [cost_input]
                                   })

        prediction['predict_total_trans_amount'] = prediction['predict_roi'] * prediction['cost']

        # 修改时间显示格式
        prediction['promotion_time'] = prediction['promotion_time'].apply(
            lambda x: x.strftime('%Y-%m-%d'))

        # 转中文字段名
        prediction = prediction.rename(columns={
            'creativity_delivery_platform': '平台',
            'promotion_channel': '渠道',
            'promotion_time': '投放时间',
            'good_series': '投流商品系列',
            'sixty_nine_code': '投流商品69码',
            'actual_price_min': '最低投流商品价格',
            'actual_price_max': '最高投流商品价格',
            'creativity_kind': '投放创意类型',
            'predict_click_through_rate': '预测点击率',
            'predict_click_conversion_rate': '预测转化率',
            'predict_roi': '预测ROI',
            'cost': '投放金额',
            'predict_total_trans_amount': '预测销售额'
        })

        return prediction

    elif promotion_channel == '品销宝':
        # 当promotion_channel为品销宝时，除creativity_kind以外的其他参数都不传递（默认值为空）
        # 读取数据
        session = get_session()
        query = session.query(pxb_cost_top_20_creativity_promotion_day)
        df = pd.read_sql(query.statement, session.bind)
        df = df[['stat_time', 'plan_name', 'unit_name', 'creativity_name', 'creativity_id',
                                          'impression_count', 'cost', 'impression_cpm', 'cost_per_click', 'click_count',
                                          'click_through_rate', 'good_favorite_count', 'good_add_to_cart_count',
                                          'trans_order_count', 'trans_amount', 'return_rate', 'conversion_rate']]

        # query_img = session.query(pxb_creativity_promotion_creativity_img)
        # df_img = pd.read_sql(query_img.statement, session.bind)
        # df_img = df_img[['creativity_id', 'creativity_image_url', 'creativity_image']]
        query_input = session.query(creativity_promotion_creativity_kind_input)
        df_input = pd.read_sql(query_input.statement, session.bind)
        df_input = df_input[
            ['creativity_promotion_channel', 'creativity_id', 'creativity_image', 'creativity_image_url',
             'creativity_kind']]
        df_input = df_input[df_input['creativity_promotion_channel'] == '品销宝']
        session.close()

        # 说明字段增加
        df = df.assign(creativity_delivery_platform='天猫')
        df = df.assign(promotion_channel='品销宝')

        # 进行连表
        # df = pd.merge(df, df_img, on=['creativity_id'], how='left')
        # df = pd.merge(df, df_input, on=['creativity_id', 'creativity_image'], how='left')
        df = pd.merge(df, df_input, on=['creativity_id'], how='left')

        # 筛选所需字段
        df = df[
            ['stat_time', 'creativity_delivery_platform', 'promotion_channel', 'plan_name', 'unit_name',
             'creativity_name',
             'creativity_id', 'creativity_image', 'creativity_kind', 'click_through_rate', 'conversion_rate', 'cost',
             'trans_amount', 'return_rate']
        ]
        df['stat_time'] = pd.to_datetime(df['stat_time'])
        df = df.fillna(np.nan)  # 将所有None转化为nan，避免运算时报错

        # 筛选creativit_kind
        df = df[df['creativity_kind'] == creativity_kind]

        if df.empty:
            return None

        # 筛选历史数据（时间）
        promotion_time = pd.to_datetime(promotion_time)
        if not df[(df['stat_time'].dt.month == promotion_time.month)].empty:
            df = df[(df['stat_time'].dt.month == promotion_time.month)]
        elif not df[(df['stat_time'].dt.quarter == promotion_time.quarter)].empty:
            df = df[(df['stat_time'].dt.quarter == promotion_time.quarter)]
        else:
            pass

        # 预测数据生成
        predict_click_through_rate = df['click_through_rate'].mean()
        predict_click_conversion_rate = df['conversion_rate'].mean()
        predict_roi = df['return_rate'].mean()
        prediction = pd.DataFrame({'creativity_delivery_platform': ['天猫'], 'promotion_channel': ['品销宝'],
                                   'creativity_kind': [creativity_kind],
                                   'promotion_time': [promotion_time],
                                   'predict_click_through_rate': [predict_click_through_rate],
                                   'predict_click_conversion_rate': [predict_click_conversion_rate], 'predict_roi': [predict_roi],
                                   'cost': [cost_input]
                                   })

        prediction['predict_total_trans_amount'] = prediction['predict_roi'] * prediction['cost']

        # 修改时间显示格式
        prediction['promotion_time'] = prediction['promotion_time'].apply(
            lambda x: x.strftime('%Y-%m-%d'))

        # 转中文字段名
        prediction = prediction.rename(columns={
            'creativity_delivery_platform': '平台',
            'promotion_channel': '渠道',
            'promotion_time': '投放时间',
            'creativity_kind': '投放创意类型',
            'predict_click_through_rate': '预测点击率',
            'predict_click_conversion_rate': '预测转化率',
            'predict_roi': '预测ROI',
            'cost': '投放金额',
            'predict_total_trans_amount': '预测销售额'
        })

        return prediction

    # 输入渠道名不为品销宝/万相台，则报错
    else:
        return tuple([False, None, '请输入正确的平台名称！（万相台/品销宝）'])





####################################################### 调用方法示意 ########################################################
# resdf = predict_competing_gmv_month('2024-04', '2025-08', '天猫')
resdf = predict_competing_gmv_big_promotion('2024', '双十一', '天猫')
# resdf = predict_promotion_creativity(promotion_channel='万相台', creativity_kind='长图', cost_input=1000, promotion_time='2024-02-07', sixty_nine_code='6921443501268', actual_price_min=5, actual_price_max=20, good_series='樱肌感')
# resdf = predict_promotion_creativity(promotion_channel='品销宝', creativity_kind='test', cost_input=1000, promotion_time='2024-01-12')
